﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NHibernate.Linq;

namespace Perpus
{
    public partial class Initial : Form
    {
        //const string konek = (@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Compaq\Documents\coba.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
       // const string konek = (@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Haris\Documents\KULIAH\Semester 6\Framework .NET (E)\FP_DOTNET_dev\Perpus\Perpus\COBA.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True");

        string konek = MappingDatabase.koneksi; 
        public Initial()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2008.ConnectionString(konek))
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Buku>())
                .ExposeConfiguration(CreateSchema)
                .BuildConfiguration();
        }

        private static void CreateSchema(Configuration cfg)
        {
            var schemaExport = new SchemaExport(cfg);
            schemaExport.Drop(false, true);
            schemaExport.Create(false, true);
            
        }

        //private ISessionFactory CreateSessionFactory()
        //{
        //    return Fluently.Configure()
        //        .Database(MsSqlConfiguration.MsSql2008.ConnectionString(konek))
        //        .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Pegawai>())
        //        .BuildSessionFactory();
        //}

        private void button2_Click(object sender, EventArgs e)
        {
            admin_MenuAwal menu_awal = new admin_MenuAwal();
            menu_awal.Show();
            this.Hide();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            TampilanAnggota anggota = new TampilanAnggota();
            anggota.Show();
            this.Hide();
        }
    }
}
